<?php

namespace app\common\model\zbtask;

use think\Model;


class Import extends Model
{

    

    

    // 表名
    protected $name = 'zbtask_import';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text',
        'status_text',
        'money_type_text',
        'is_import_text'
    ];
    

    
    public function getTypeList()
    {
        return ['0' => __('Type 0'), '1' => __('Type 1'), '2' => __('Type 2')];
    }

    public function getStatusList()
    {
        return ['0' => '待验证', '1' => '正确', 2=> '错误'];
    }

    public function getMoneyTypeList()
    {
        return ['1' => __('Money_type 1'), '2' => __('Money_type 2')];
    }

    public function getIsImportList()
    {
        return ['0' => __('Is_import 0'), '1' => __('Is_import 1')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getMoneyTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['money_type']) ? $data['money_type'] : '');
        $list = $this->getMoneyTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsImportTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_import']) ? $data['is_import'] : '');
        $list = $this->getIsImportList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function zbtask()
    {
        return $this->belongsTo('app\common\model\zbtask\Zbtask', 'task_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
